﻿<div class="separator" style="margin-bottom:0px"></div>
<div class="secondary-module">
<h2 style="text-align:center;margin-bottom:15px;">Calcular índice massa corporal</h2></div>
@using (Html.BeginForm("IndiceMassaCorporal", "Tools", FormMethod.Get, new { onsubmit="return validate()" }))
{
<div>
<b>A sua altura (em centimetros):</b><br />
<input name="altura" id="altura" type="text" class="input_text intOnly" style="width: 76px;" maxlength="3"/>
</div>
<div style="margin-top:10px">
<b>O seu peso (em Kilogramas):</b><br />
<input name="peso" id="peso" type="text" class="input_text intOnly" style="width: 76px;" maxlength="3"/>
</div>
<div style="margin-top:15px;">
<input  type="submit" value="Calcular" id="btnPostIMC"/>
</div>
}
<script type="text/javascript">
    $(document).ready(function () {
        $(".intOnly").keydown(function (e) {
            if (e.shiftKey || e.ctrlKey || e.altKey) { // if shift, ctrl or alt keys held down
                e.preventDefault();         // Prevent character input
            } else {
                var n = e.keyCode;
                if (!((n == 8)              // backspace
        || (n == 46)                // delete
        || (n >= 35 && n <= 40)     // arrow keys/home/end
        || (n >= 48 && n <= 57)     // numbers on keyboard
        || (n >= 96 && n <= 105))   // number on keypad
        ) {
                    e.preventDefault();     // Prevent character input
                }
            }
        });
    });

    function validate() {
        if (isNaN($('.intOnly').val())) {
            return false;
        }
        return true;
    }
</script>